<?php
$content->assign("formaction", SECURE_URL.$lang."/process-reservations-form/");
$content->assign("reservationsformintro", $content->langmsg["reservationsformintro"]);
$content->assign("namelabel", $content->langmsg["namelabel"]);
$content->assign("lastnamelabel", $content->langmsg["lastnamelabel"]);
$content->assign("niflabel", $content->langmsg["niflabel"]);
$content->assign("agelabel", $content->langmsg["agelabel"]);
$content->assign("emaillabel", $content->langmsg["emaillabel"]);
$content->assign("addresslabel", $content->langmsg["addresslabel"]);
$content->assign("townlabel", $content->langmsg["townlabel"]);
$content->assign("zipcodelabel", $content->langmsg["zipcodelabel"]);
$content->assign("provincelabel", $content->langmsg["provincelabel"]);
$content->assign("countrylabel", $content->langmsg["countrylabel"]);
$content->assign("phone1label", $content->langmsg["phone1label"]);
$content->assign("phone2label", $content->langmsg["phone2label"]);
$content->assign("initialdatelabel", $content->langmsg["initialdatelabel"]);
$content->assign("observationslabel", $content->langmsg["observationslabel"]);
$content->assign("companionslabel", $content->langmsg["companionslabel"]);
$content->assign("addcompanionlabel", $content->langmsg["addcompanionlabel"]);
$content->assign("deletecompanionlabel", $content->langmsg["deletecompanionlabel"]);
$content->assign("captchalabel", $content->langmsg["captchalabel"]);
$content->assign("captchatext", $content->langmsg["captchatext"]);
$content->assign("regeneratecaptcha", $content->langmsg["regeneratecaptcha"]);
$content->assign("maxcompanions", MAX_COMPANIONS);
$content->assign("tourlabel", $content->langmsg["tourlabel"]);

// Acompañantes
$cboxes = "<div id=\"companionBoxesDivider\" class=\"horizontal-divider\" style=\"display: none; height: 10px; background: transparent\">&nbsp;</div>\n";
for ($i=1; $i<=MAX_COMPANIONS; $i++) {
	$border = ($i>1 ? "; border-top: 1px dotted #bbb" : "");
	$cboxes .= "<div id=\"companionBox$i\" class=\"companionbox\" style=\"display: none".$border."\">".
			   "<b>".$i.".</b>&nbsp;&nbsp;&nbsp;".
			   $content->langmsg["namelabel"].": <input type=\"text\" name=\"companionName$i\" id=\"companionName$i\" maxlength=\"100\" class=\"textfield4\" />&nbsp;&nbsp;&nbsp;".
			   $content->langmsg["lastnamelabel"].": <input type=\"text\" name=\"companionLastName$i\" id=\"companionLastName$i\" maxlength=\"200\" class=\"textfield4\" />&nbsp;&nbsp;&nbsp;".
			   $content->langmsg["niflabel"].": <input type=\"text\" name=\"companionNif$i\" id=\"companionNif$i\" maxlength=\"20\" class=\"textfield4\" />&nbsp;&nbsp;&nbsp;".
			   $content->langmsg["agelabel"].": <input type=\"text\" name=\"companionAge$i\" id=\"companionAge$i\" maxlength=\"3\" class=\"textfield4\" />".
			   "</div>\n";
}
$content->assign("companionboxes", $cboxes);

// Camino
$noTourSelected = true;
$tourName = "";
$tourId = (isset($_POST["tourId"]) ? $_POST["tourId"] : "");

$query = "SELECT title FROM tour_content WHERE tour_id = '$tourId' AND language = '$lang'";
$res20 = $db->runQuery($query);
if ($db->getRowCount($res20)) {
	$row20 = $db->getRow($res20);
	$tourName = utf8_encode($row20["title"]);
	$noTourSelected = false;
}

// Lista de caminos
$listOfTours = "";
$query = "SELECT tc.id, tc.title
		  FROM tour_content tc
		  JOIN tours t ON tc.tour_id = t.id
		  WHERE tc.language = '$lang'
		  AND tc.tour_id != 4
		  AND t.status = 1
		  ORDER BY t.id";
$res21 = $db->runQuery($query);
if (!$db->getRowCount($res21)) {
	$listOfTours .= $content->langmsg["errorRecoveringListOfTours"];
} else {
	$listOfTours .= "<option value=\"\"></option>\n";
	while ($row21 = $db->getRow($res21)) {
		$listOfTours .= "<option value=\"".$row21["id"]."\">".utf8_encode($row21["title"])."</option>\n";
	}
}

// Tour 6 start date picker
$tour6StartDatePicker = $content->langmsg["startdatepickerlabel"].": ".
"<select name=\"tour6StartDate\" id=\"tour6StartDate\" class=\"combobox\">";
foreach ($content->langmsg["tour6startdates"] as $key => $val) {
	$tour6StartDatePicker .= "<option value=\"$key\">$val</option>";
}
$tour6StartDatePicker .= "</select>";
$content->assign("tour6startdatepicker", $tour6StartDatePicker);

// Tour 7 start date picker
$tour7StartDatePicker = $content->langmsg["startdatepickerlabel"].": ".
"<select name=\"tour7StartDate\" id=\"tour7StartDate\" class=\"combobox\">";
foreach ($content->langmsg["tour7startdates"] as $key => $val) {
	$tour7StartDatePicker .= "<option value=\"$key\">$val</option>";
}
$tour7StartDatePicker .= "</select>";
$content->assign("tour7startdatepicker", $tour7StartDatePicker);

// Generic start date picker
$genericStartDatePicker = $content->langmsg["startdatepickerlabel"].": ".
"<select name=\"genericStartDay\" id=\"genericStartDay\" class=\"combobox\">".$content->generateComboOptions("days", date("j"))."</select> ".
"<select name=\"genericStartMonth\" id=\"genericStartMonth\" class=\"combobox\">".$content->generateComboOptions("months", date("n"))."</select>";
$content->assign("genericstartdatepicker", $genericStartDatePicker);

// Pintamos lo de los caminos
if ($noTourSelected) {
	$selectedTour = $content->langmsg["notourselected"].". ".$content->langmsg["choosetourlabel"].": <select name=\"listOfTours\" id=\"listOfTours\" class=\"combobox\" onchange=\"this.blur();\">".$listOfTours."</select>\n";
	$tour6StartDatePickerDisplay = "none";
	$tour7StartDatePickerDisplay = "none";
	$genericStartDatePickerDisplay = "none";
} else {
	$selectedTour = "<strong>".$tourName."</strong>\n";
	if ($tourId == 6) {
		$tour6StartDatePickerDisplay = "block";
		$tour7StartDatePickerDisplay = "none";
		$genericStartDatePickerDisplay = "none";
	} else if ($tourId == 7) {
		$tour6StartDatePickerDisplay = "none";
		$tour7StartDatePickerDisplay = "block";
		$genericStartDatePickerDisplay = "none";
	} else {
		$tour6StartDatePickerDisplay = "none";
		$tour7StartDatePickerDisplay = "none";
		$genericStartDatePickerDisplay = "block";
	}
}
$content->assign("selectedtour", $selectedTour);
$content->assign("tour6startdatepickerdisplay", $tour6StartDatePickerDisplay);
$content->assign("tour7startdatepickerdisplay", $tour7StartDatePickerDisplay);
$content->assign("genericstartdatepickerdisplay", $genericStartDatePickerDisplay);
$content->assign("tourid", $tourId);

include(INCLUDES_DIR."reservation-policy.php");
?>
